package team.zero.lemon.module.cms.service;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import team.zero.lemon.common.exception.CustomException;
import team.zero.lemon.common.service.CrudService;
import team.zero.lemon.module.cms.dao.ICategoryDao;
import team.zero.lemon.module.cms.entity.Category;

import java.util.List;

/**
 * Created by bolin on 2016/10/24.
 */
@Service
public class CategoryService extends CrudService<ICategoryDao, Category> {

    @Cacheable(value = "CategoryEhcache")
    public List<Category> findByParentId(Category dic) {
        try {
            return dao.findByParentId(dic);
        } catch (Exception e) {
            throw new CustomException(e);
        }
    }
    @Cacheable(value = "CategoryEhcache")
    public Category findByParentIdAndName(int prarentId, String name) {
        try {
            return dao.findByParentIdAndName(prarentId, name);
        } catch (Exception e) {
            throw new CustomException(e);
        }
    }
}